package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.controller.BaseController;
import com.chinatechstar.component.commons.result.ListResult;
import com.chinatechstar.component.commons.result.ResultBuilder;
import com.chinatechstar.component.commons.supports.PageData;
import com.zjcode.cdcer.model.ZjcodePlanFollowUp;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.PlanFollowUpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ZQM
 * @date 2023/9/21 16:00
 */
@RestController
@RequestMapping("/v1/followup")
public class PlanFollowUpController extends BaseController {

    @Autowired
    private PlanFollowUpService followUpService;

    /**
     * 添加计划随访
     */
    @PostMapping("/add")
    public JsonObj add(@RequestBody ZjcodePlanFollowUp followUp) {
        return followUpService.add(followUp);
    }

    /**
     * 修改计划随访
     */
    @PostMapping("/edit")
    public JsonObj edit(@RequestBody ZjcodePlanFollowUp followUp) {
        return followUpService.edit(followUp);
    }

    /**
     * 查询计划随访（单个）
     */
    @GetMapping("/selById")
    public JsonObj selById(@RequestParam String id) {
        return followUpService.selById(id);
    }

    /**
     * 查询计划随访（列表）
     */
    @PostMapping("/selList")
    public ListResult<Object> selList(@RequestBody PageData pageData) {
        return ResultBuilder.buildListSuccess(followUpService.selList(pageData));
    }

    /**
     * 删除计划随访
     */
    @GetMapping("/del")
    public JsonObj del(@RequestParam String id) {
        return followUpService.del(id);
    }

    /**
     * 随访状态修改
     * @param id 当前记录主键
     * @param status 随访状态：1未随访，2已随访
     */
    @GetMapping("/changeStatus")
    public JsonObj changeStatus(@RequestParam String id, @RequestParam Integer status) {
        return followUpService.changeStatus(id, status);
    }
}
